home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 3.0 KB | 126 lines | [TEXT/MPS ] |
- program Hello;
- { Copyright 1990 The NetWork Project, StatLab Heidelberg. }
-
- uses MemTypes, QuickDraw, OSIntf, ToolIntf, SysEqu;
-
- PROCEDURE InitToolBox;
- const callsToMoreMasters=10;
- VAR
- i : integer;
- p : GrafPtr;
- m : MenuHandle;
- applZone: THz;
- oldMoreMast: INTEGER;
-
- BEGIN
- MaxApplZone;
-
- { Here is a trick - Stolen from MacApp- sugested by Jerome C. }
- applZone := ApplicZone;
- oldMoreMast := applZone^.moreMast;
- applZone^.moreMast := oldMoreMast * callsToMoreMasters;
- MoreMasters;
- applZone^.moreMast := oldMoreMast;
-
- InitGraf(@thePort); {initialize QuickDraw}
- InitFonts; {initialize Font Manager}
- InitWindows; {initialize Window Manager}
- InitMenus; {initialize Menu Manager}
- TEInit; {initialize TextEdit}
- InitDialogs(NIL); {initialize Dialog Manager}
- InitCursor; {call QuickDraw to make cursor (pointer) an arrow}
-
- m := GetMenu (1);
- AddResMenu (m, 'DRVR');
- InsertMenu (m, 0);
- m := GetMenu (2); InsertMenu (m, 0);
- END;
-
- type RgnHPtr = ^RgnHandle; IntPtr = ^integer;
-
- var savedgrayrgn, newgrayrgn, mousergn : RgnHandle;
- w : WindowPtr; pw : integer; ev : EventRecord;
- mousepos : Point;
- theDialog:DialogPtr;
-
- PROCEDURE CenterRect(VAR GlobR : rect;vh:vhselect);
- {Center a rectangle to center of screen}
- VAR xdel, ydel,screenWidth,screenHeight: integer;
- BEGIN
- with screenbits do
- begin
- screenwidth := bounds.right - bounds.left;
- screenHeight := bounds.bottom - bounds.top;
- end;
- xdel:=0;ydel:=0;
- WITH GlobR DO
- if vh=h then xdel := ((screenWidth - (right - left)) DIV 2) - left
- else ydel := ((screenHeight - (bottom - top)) DIV 2) - top;
- offsetRect(GlobR, xdel, ydel);
- END;
-
- PROCEDURE CenterWindow(wptr:windowptr;vh:vhselect);
- {Center a window to center of screen}
- CONST
- MakeFront = False;
- VAR
- r, rbound : rect;
- BEGIN
- if Wptr<>nil then begin
- r := wptr^.portRect;
- rbound := wptr^.portbits.bounds;
- OffsetRect(r, -rbound.left, -rbound.top);
- CenterRect(R,vh);
- MoveWindow(wptr, r.left, r.top, MakeFront);
- end;
- END;
-
-
- var tempAlert : AlertTHndl;
- i:integer;
- stoptime:longint;
- BEGIN
- InitToolBox;
- drawmenubar;
-
- theDialog := GetNewDialog(130,NIL,Pointer(-1));
- IF theDialog=NIL THEN
- BEGIN {Fatal:could not process dialog}
- sysbeep(2);
- END
- ELSE BEGIN
-
- CenterWindow(theDialog,h);
- showwindow(theDialog);
- selectwindow(theDialog);
- setport(thedialog);
- invalrect(thedialog^.portrect);
- Beginupdate(theDialog);
- drawdialog(theDialog);Endupdate(theDialog);
- END;
-
- stoptime:=tickcount+60*10;
-
- REPEAT
-
- IF WaitNextEvent (EveryEvent, ev, 60, mousergn) THEN
- CASE ev.what OF
- activateEvt: stoptime:=tickcount+60*10; {reset the stop time}
-
- updateEvt : BEGIN
-
- IF isDialogEvent(ev) THEN
- UpdtDialog(Dialogptr(ev.Message),thePort^.visRgn);
- stoptime:=tickcount+60*10; {reset the stop time}
-
- END;
- diskEvt : IF Point (ev.message).v <> noErr THEN
- IF Eject (NIL, Point (ev.message).h) <> noErr THEN;
- { Eject bad disks . }
- END;
-
- UNTIL (ev.what IN [keydown..autoKey, mousedown, diskEvt, app4Evt])
- OR (tickcount>stoptime);
-
- END.
-